package org.shj.pattern.simplefactory;

class CashReturn extends Cash{
	
	private double condition = 0.0d;
	private double moneyReturn = 0.0d;
	
	//返利收费，比如满300返50，则 condition为300， moneyReturn为50
	public CashReturn(double condition, double moneyReturn){
		this.condition = condition;
		this.moneyReturn = moneyReturn;
	}

	@Override
	public double acceptCash(double money) {
		double result = money;
		if(money >= condition){
			result = money - Math.floor(money / condition) * moneyReturn;
		}
		return result;
	}

}
